class IssuesLabels
  attr_accessor :github

  def initialize(github)
    @github = github
  end

  def listRepoLabels(repo, user=nil)
    url = 'repos/%s/%s/labels' % [repo, user]
    @github.get(url)
  end

  def getLabel(repo, id, user=nil)
    url = 'repos/%s/%s/labels/%s' % [repo, user, id]
    @github.get(url)
  end

  def createLabel(repo, name, color, user=nil)
    params = {
        :name => name,
        :color => color
    }
    data = params.to_json
    url = 'repos/%s/%s/labels' % [repo, user]
    @github.post(url, data)
  end

  def editLabel(repo, id, name, color, user=nil)
    params = {
        :name => name,
        :color => color
    }
    data = params.to_json
    url = 'repos/%s/%s/labels/%s' % [repo, user, id]
    @github.patch(url, data)
  end

  def deleteLabel(repo, id, user=nil)
    url = 'repos/%s/%s/labels/%s' % [repo, user, id]
    @github.delete(url)
  end

  def getIssueLabels(repo, id, user=nil)
    url = 'repos/%s/%s/issues/%s/labels' % [repo, user, id]
    @github.get(url)
  end

  def addIssueLabel(repo, id, labels, user=nil)
    params = labels
    data = params.to_json
    url = 'repos/%s/%s/issues/%s/labels' % [repo, user, id]
    @github.post(url, data)
  end

  def deleteIssueLabel(repo, issue_id, label_id, user=nil)
    url = 'repos/%s/%s/issues/%s/labels/%s' % [repo, user, issue_id, label_id]
    @github.delete(url)
  end

  def replaceIssueLabels(repo, id, labels, user=nil)
    params = labels
    data = params.to_json
    url = 'repos/%s/%s/issues/%s/labels' % [repo, user, id]
    @github.put(url, data)
  end

  def removeIssueLabels(repo, id, user=nil)
    url = 'repos/%s/%s/issues/%s/labels' % [repo, user, id]
    @github.delete(url)
  end

  def getIssueMilestoneLabels(repo, id, user=nil)
    url = 'repos/%s/%s/milestones/%s/labels' % [repo, user, id]
    @github.get(url)
  end
end
